<?php
include_once("../includes/config.php");
$blog = $_GET['blog'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="robots" content="index,follow" />
<link href="<?php echo $baseurl; ?>default.css" rel="stylesheet" title="Feuille de style principale" type="text/css" media="screen" />

<?php
if($blog)
echo '<title>Liste des articles notés de '.$blog.'</title>';
else
echo '<title>Consulter les statistiques des notes</title>';
?>

<style type="text/css">
table
{
   border-collapse: collapse;
}
td,th
{
   border: 1px solid black;
   text-align:center;
}
</style>

</head>
<body>
<div id="conteneur">

<div id="header">

<div id="col1">
<h1><a href="<?php echo $baseurl; ?>"><?php echo $nameblog; ?></a></h1>
<p class="baseline"><?php echo $baseline; ?></p>
</div>

<?php
include('../includes/pub.php');
?>

</div>

<div id="menu">
<?php
include('../includes/menu.php');
?>
</div>

<div id="blog">

<?php
if($blog)
{
?>
<h2>Liste des articles notés de <?php echo $blog; ?></h2>   
<?php

$rep = $blog.'/';
if(@$dir = opendir($rep))
{
?>
<table>
   <tr>
       <th>Article</th>
       <th>Moyenne</th>
       <th>Nombres de votes</th>
   </tr>
<?php
while ($f = readdir($dir)) {
   if(is_file($rep.$f)) {

    $fichier = fopen($rep.$f, "r+");
	$texte = fgets($fichier);
	//echo $texte;
	$texte = explode ('|', $texte);
	$article[] = array($f => $texte[0]/$texte[1].'|'.$texte[1]);
   }
}
closedir($dir);

sort($article);

foreach($article as $id => $element)
{
	foreach($element as $article => $chiffres)
	{
	$article = explode('.', $article);
	$chiffre = explode('|', $chiffres);
	echo '<tr><td><a href="http://'.$blog.'.skyrock.com/article_'.$article[0].'.html">'.$article[0].'</a></td><td>'.$chiffre[0].'</td><td>'.$chiffre[1].'</td><tr />';
	}

}
echo '</table>';
}
else
{
echo '<p>Pas de notes pour ce blog...</p>';
}

echo '<h2>Consulter les notes d\'un autre blog ?</h2>';
}
else
{
echo '<h2>Consulter les notes de votre blog</h2>';
}
?>
<form method="get" action="">
<p>
Votre blog : <input type="text" name="blog" value="" />.skyrock.com
<br /><input type="submit" value="Voir les statistiques" />
</p>
</form>
<p><a href="index.php">Générer les codes à insérer sur votre blog</a></p>
</div>

<div id="sidebar-box">

<div id="sidebar">
<?php include('../includes/sidebar_content.php'); ?> </div>

</div>

</div>
</body>
</html>